package com.cloud.sms.service;

import com.cloud.sms.dao.SmsWhiteListMapper;
import com.cloud.sms.interceptor.ServiceException;
import com.cloud.sms.model.SmsWhiteList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @describe 短信防御白名单
 * 
 * @author ruanpeng
 * @date 2014年7月19日
 */
@Service
public class SmsWhiteListService {

	@Autowired
	private SmsWhiteListMapper smsWhiteListMapper;

	public int insertSelective(SmsWhiteList model) throws ServiceException {
		int len;
		try {
			len = smsWhiteListMapper.insertSelective(model);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException();
		}
		return len;
	}

	public int deleteByPrimaryKey(int id) throws ServiceException {
		int len;
		try {
			len = smsWhiteListMapper.deleteByPrimaryKey(id);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException();
		}
		return len;
	}

	public int updateByPrimaryKeySelective(SmsWhiteList model) throws ServiceException {
		int len;
		try {
			len = smsWhiteListMapper.updateByPrimaryKeySelective(model);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException();
		}
		return len;
	}

	public SmsWhiteList selectByPrimaryKey(int id) {
		return smsWhiteListMapper.selectByPrimaryKey(id);
	}
	
	public SmsWhiteList selectByIpAddress(String ipAddress) {
		return smsWhiteListMapper.selectByIpAddress(ipAddress);
	}	

}
